package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.ZtfVideoTable;
import com.ruoyi.system.service.IZtfVideoTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/system/table")
@Api(tags = "后台视频相关接口")
public class ZtfVideoTableController extends BaseController
{
    @Autowired
    private IZtfVideoTableService ztfVideoTableService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:table:list')")
    @GetMapping("/list")
    @ApiOperation("视频列表")
    public TableDataInfo list(ZtfVideoTable ztfVideoTable)
    {
        startPage();
        List<ZtfVideoTable> list = ztfVideoTableService.selectZtfVideoTableList(ztfVideoTable);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:table:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZtfVideoTable ztfVideoTable)
    {
        List<ZtfVideoTable> list = ztfVideoTableService.selectZtfVideoTableList(ztfVideoTable);
        ExcelUtil<ZtfVideoTable> util = new ExcelUtil<ZtfVideoTable>(ZtfVideoTable.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:table:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取视频详情")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ztfVideoTableService.selectZtfVideoTableById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:table:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("视频新增")
    public AjaxResult add(@RequestBody ZtfVideoTable ztfVideoTable)
    {
       //生成视频id
        ztfVideoTable.setId(IdUtils.simpleUUID());
        return toAjax(ztfVideoTableService.insertZtfVideoTable(ztfVideoTable));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:table:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("视频修改")
    public AjaxResult edit(@RequestBody ZtfVideoTable ztfVideoTable)
    {
        return toAjax(ztfVideoTableService.updateZtfVideoTable(ztfVideoTable));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:table:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除视频")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ztfVideoTableService.deleteZtfVideoTableByIds(ids));
    }
}
